<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    request.setAttribute("basePath", basePath);
%>
<%@ include file="/resources/js/easyui/taglibs.jsp" %>
<%@ include file="/resources/js/wechat/_wechatui.jsp" %>
<!DOCTYPE>
<html>
<head>
    <title>微信</title>
</head>
<body>
<div class="loading"></div>
<!-- header -->
<header class='login_header'>
    <a href="javascript:history.go(-1);" class="top_fh">微信</a>
</header>
<!-- header end -->

<div class="page login_page">
    <div class="login_inner">
        <div class="zh_title"><em class="zc_tile">注册帐号</em></div>
        <form id="myForm" name="myForm">
            <div class="lgin_form">
                <div class='lg_zh'><input name="username" type="text" placeholder="请输入用户名"></div>
                <div class='lg_sr'><input name="mobile" type="text" placeholder="请输入手机号"></div>
                <div class='lg_sr'><input name="email" type="text" placeholder="请输入邮箱"></div>
                <div class='lg_yzm'><input name="code" type="text" placeholder="请输入验证码"><a href="JavaScript:;"
                                                                               class="hqzma" id="getMoblieCode">获取验证码</a></div>
                <div class="lg_button"><a href="javascript:void(0);">下一步</a></div>
            </div>
            <div class="lgin_form">
                <div class='lg_ps'><input name="password" type="password" placeholder="请设置密码"></div>
                <div class='lg_qrmm'><input id="confirmPassword" type="password" placeholder="请确认密码"></div>
                <div class="lg_button"><a href="javascript:void(0);" id="register_submit">立即注册</a></div>
            </div>
        </form>
    </div>
    <div class="footer_bz">游艺云</div>
</div>
</body>
</html>
<script>

    $("#getMoblieCode").click(function(){
        var moblie = $("input[name='mobile']").val();
        alert(moblie);
        if(typeof(moblie) == "undefined" || moblie.length == 0){
            alert('温馨提示:请输入您的手机号码');
        }else{
            $.ajax({
                url:'${basePath}user/getMobileCode',
                type : 'GET',
                data : {"moblie" : moblie},
                traditional:true,
                error: function (response) {
                    ViewHelper.func.ajaxErrorMessage(response);
                },
                success: function (ret) {
                    console.log(ret);
                    if(ret.result) {
                        alert('温馨提示:'+ret.info);

                    }else{
                        alert('提示:保存失败!');
                    }
                }
            });
        }
    });


    $("#register_submit").click(function(){
            var login_password = $("[name='password']").val();
            var transfer_password = $("[name='transferpassword']").val();
            var code = $("#mobilecode").val();
            $("[name='password']").val(b64_hmac_md5(login_password,login_password));
            $("[name='transferpassword']").val(b64_hmac_md5(transfer_password,transfer_password));

            $.ajax({
                url:'${basePath}user/' + code + '/submitUserInfo',
                type : 'POST',
                data : $("#addform").serialize(),
                async : false,
                traditional:true,
                error: function (response) {
                    ViewHelper.func.ajaxErrorMessage(response);
                },
                success: function (ret) {
                    if(ret.result) {
                        $.messager.confirm('温馨提醒', ret.info, function (r) {
                            if (r) {
                                alert("完善个人信息");
                            }else{
                                alert("跳转首页");
                            }
                        });
                    }else{
                        $.messager.alert('温馨提醒',ret.info,'error');
                    }
                }
            });
    });

</script>